<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
  <head>
    <th:block th:replace="~{/_include/header}" />
    <title>[[${bundle.L('添加实体')}]]</title>
    <style>
      .text-muted.desc {
        max-width: 80%;
      }
      .init-models {
        margin: 0 -10px;
      }
      .dialog-footer {
        margin: 15px -40px 0;
        padding-top: 20px;
      }
    </style>
  </head>
  <body class="dialog">
    <div class="main-content pt-1">
      <div class="tab-container">
        <ul class="nav nav-tabs">
          <li class="nav-item"><a class="nav-link active" href="#MANUAL" data-toggle="tab">[[${bundle.L('手动')}]]</a></li>
          <li class="nav-item">
            <a class="nav-link" href="#COPY" data-toggle="tab">[[${bundle.L('复制')}]]</a>
          </li>
          <li class="nav-item">
            <a class="nav-link J_imports" href="#IMPORTS" data-toggle="tab"> <i class="icon zmdi zmdi-cloud-outline-alt"></i> [[${bundle.L('从 RB 仓库导入')}]] </a>
          </li>
        </ul>
        <div class="tab-content m-0 pb-0">
          <div class="tab-pane active" id="MANUAL">
            <div class="form">
              <div class="form-group row">
                <label class="col-sm-3 col-form-label text-sm-right">[[${bundle.L('实体名称')}]]</label>
                <div class="col-sm-7">
                  <input class="form-control form-control-sm" type="text" id="entityLabel" maxlength="40" />
                </div>
              </div>
              <div class="form-group row">
                <label class="col-sm-3 col-form-label text-sm-right">[[${bundle.L('备注')}]]</label>
                <div class="col-sm-7">
                  <textarea class="form-control form-control-sm row2x" id="comments" maxlength="100" th:placeholder="${bundle.L('(选填)')}"></textarea>
                </div>
              </div>
              <div class="form-group row pt-2">
                <label class="col-sm-3 col-form-label text-sm-right"></label>
                <div class="col-sm-7">
                  <label class="custom-control custom-control-sm custom-checkbox custom-control-inline mb-0">
                    <input class="custom-control-input" type="checkbox" id="nameField" />
                    <span class="custom-control-label">[[${bundle.L('添加一个名称字段')}]]</span>
                  </label>
                </div>
              </div>
              <div class="form-group row pt-0">
                <label class="col-sm-3 col-form-label text-sm-right"></label>
                <div class="col-sm-7">
                  <label class="custom-control custom-control-sm custom-checkbox custom-control-inline mb-0">
                    <input class="custom-control-input" type="checkbox" id="seriesField" />
                    <span class="custom-control-label">[[${bundle.L('添加一个自动编号字段')}]]</span>
                  </label>
                </div>
              </div>
              <div class="form-group row pt-0">
                <label class="col-sm-3 col-form-label text-sm-right"></label>
                <div class="col-sm-7">
                  <label class="custom-control custom-control-sm custom-checkbox custom-control-inline mb-0">
                    <input class="custom-control-input" type="checkbox" id="isDetail" />
                    <span class="custom-control-label">
                      [[${bundle.L('这是明细实体')}]]
                      <i class="zmdi zmdi-help zicon" data-toggle="tooltip" th:title="${bundle.L('通过明细实体可以更好的组织业务关系。例如订单明细通常依附于订单，而非独立存在')}"></i>
                    </span>
                  </label>
                </div>
              </div>
              <div class="form-group row J_mainEntity hide">
                <label class="col-sm-3 col-form-label text-sm-right">[[${bundle.L('选择主实体')}]]</label>
                <div class="col-sm-7">
                  <select class="form-control form-control-sm" id="mainEntity"></select>
                </div>
              </div>
              <div class="form-group row footer">
                <div class="col-sm-7 offset-sm-3">
                  <button class="btn btn-primary new" type="button">[[${bundle.L('确定')}]]</button>
                  <button class="btn btn-link" type="button" onclick="parent.RbModal.hide()">[[${bundle.L('取消')}]]</button>
                </div>
              </div>
            </div>
          </div>
          <div class="tab-pane" id="COPY">
            <div class="form">
              <div class="form-group row">
                <label class="col-sm-3 col-form-label text-sm-right">[[${bundle.L('复制哪个实体')}]]</label>
                <div class="col-sm-7">
                  <select class="form-control form-control-sm" id="copySourceEntity"></select>
                </div>
              </div>
              <div class="form-group row">
                <label class="col-sm-3 col-form-label text-sm-right">[[${bundle.L('实体名称')}]]</label>
                <div class="col-sm-7">
                  <input class="form-control form-control-sm" type="text" id="newEntityLabel" maxlength="40" />
                </div>
              </div>
              <div class="form-group row hide J_newDetailLabel">
                <label class="col-sm-3 col-form-label text-sm-right">[[${bundle.L('明细实体名称')}]]</label>
                <div class="col-sm-7">
                  <input class="form-control form-control-sm" type="text" id="newDetailLabel" maxlength="40" th:placeholder="${bundle.L('(选填)')}" />
                  <p class="form-text">[[${bundle.L('不填写则不复制明细实体')}]]</p>
                </div>
              </div>
              <div class="form-group row footer">
                <div class="col-sm-7 offset-sm-3">
                  <button class="btn btn-primary copy" type="button">[[${bundle.L('确定')}]]</button>
                  <button class="btn btn-link" type="button" onclick="parent.RbModal.hide()">[[${bundle.L('取消')}]]</button>
                </div>
              </div>
            </div>
          </div>
          <div class="tab-pane" id="IMPORTS">
            <div id="metaschemas"></div>
            <div class="mt-2 text-right hide">
              <a href="https://getrebuild.com/market/go/1220-rb-store" class="link" target="_blank">[[${bundle.L('提交数据到 RB 仓库')}]]</a>
            </div>
          </div>
        </div>
      </div>
    </div>
    <th:block th:replace="~{/_include/footer}" />
    <script th:src="@{/assets/js/admin/init-models.js}" type="text/babel"></script>
    <script th:src="@{/assets/js/metadata/entity-new.js}" type="text/babel"></script>
  </body>
</html>
